home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000…tember: Reference Library / Dev.CD Sep 00 RL Disk 1.toast / mac / Technical Documentation / Develop / develop Issue 23 / develop Issue 23 code / ProjectDrag 1.1b8.sea / ProjectDrag 1.1b8 / Sources / ProjectDrag Sources / FileCancel.c / FileCancel.c
Encoding:
C/C++ Source or Header  |  1995-09-07  |  2.7 KB  |  107 lines  |  [TEXT/MPS ]

  1. /* FileCancel.c: Cancelation utility routine for ProjectDrag.
  2.  *
  3.  * A set of applets for drag and drop source control by Tim Maroney.
  4.  * See develop, issue 23 for details.
  5.  *
  6.  * Built on DropShell by Leonard Rosenthol, Stephan Somogyi, and Marshall Clow,
  7.  * and using the MoreFiles utilities by Jim Luther.
  8.  *
  9.  * This software is free, but don't modify and redistribute it without
  10.  * changing the status window to indicate your name and your changes!
  11.  */
  12.  
  13.  
  14. #include <Errors.h>
  15.  
  16. #include "SourceServer.h"
  17. #include "TasksAndErrors.h"
  18. #include "FileCancel.h"
  19.  
  20.  
  21. OSErr FileCancel(FSSpec *file, CKIDHandle theCKID)
  22. {
  23.     Str255 projectName;
  24.     AEDesc command;
  25.     OSErr err;
  26.         
  27.     if ((*theCKID)->modifyReadOnly)
  28.     {
  29.         /* MRO -- orphan & create a CheckOut command for SourceServer
  30.          * OrphanFiles <file>
  31.          * CheckOut -y -d <dir> -project <project> <file>
  32.          */
  33.  
  34.         /* mount the project */
  35.         err = MountProjectFromCKID(theCKID, projectName);
  36.         if (err != noErr) return err;
  37.  
  38.         /* orphan the file */
  39.         err = CreateCommand(&command, "OrphanFiles");
  40.         if (err == noErr)
  41.             err = AddFileNameArg(&command, file);
  42.         if (err != noErr)
  43.         {
  44.             AEDisposeDesc(&command);
  45.             RaiseErrorNumber(err);
  46.             return err;
  47.         }
  48.         err = SendCommand(&command);
  49.         if (err != noErr) return err;
  50.         
  51.         /* create the checkout command */
  52.         err = CreateCommand(&command, "CheckOut");
  53.         if (err == noErr)
  54.             err = AddPStringArg(&command, "\p-y");
  55.         if (err == noErr)
  56.             err = AddDirArg(&command, file->vRefNum, file->parID);
  57.         if (err == noErr)
  58.             err = AddProjectArg(&command, projectName);
  59.         if (err == noErr)
  60.             err = AddPStringArg(&command, file->name);
  61.         if (err != noErr)
  62.         {
  63.             AEDisposeDesc(&command);
  64.             RaiseErrorNumber(err);
  65.             return err;
  66.         }
  67.         
  68.         err = SendCommand(&command);
  69.         if (err == noErr)
  70.             SetFileLabel(file, 6, NULL); /* modify the label to red (6) */
  71.         return err;
  72.     }
  73.     else
  74.     {        
  75.         /* checked out for modify -- create a CheckOut -cancel command for SourceServer
  76.          * CheckOut -cancel -y -d <dir> -project <project> <file>
  77.          */
  78.         
  79.         /* mount the project */
  80.         err = MountProjectFromCKID(theCKID, projectName);
  81.         if (err != noErr) return err;
  82.  
  83.         err = CreateCommand(&command, "CheckOut");
  84.         if (err == noErr)
  85.             err = AddCStringArg(&command, "-cancel");
  86.         if (err == noErr)
  87.             err = AddCStringArg(&command, "-y");
  88.         if (err == noErr)
  89.             err = AddDirArg(&command, file->vRefNum, file->parID);
  90.         if (err == noErr)
  91.             err = AddProjectArg(&command, projectName);
  92.         if (err == noErr)
  93.             err = AddPStringArg(&command, file->name);
  94.         if (err != noErr)
  95.         {
  96.             AEDisposeDesc(&command);
  97.             RaiseErrorNumber(err);
  98.             return err;
  99.         }
  100.         
  101.         err = SendCommand(&command);
  102.         if (err == noErr)
  103.             SetFileLabel(file, 6, NULL); /* modify the label to red (6) */
  104.         return err;
  105.     }
  106. }
  107.